﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Stock_In_View_Product_Sort_Tree.aspx.cs" Inherits="JKF.Web.Stock.In.Stock_In_View_Product_Sort_Tree" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>获取树</title> 
     <link href="/App_Themes/Theme1/common.css" rel="stylesheet" type="text/css" /> 
    <link href="/css/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
     <link href="/js/JQueryzTreev3.5/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" />
    <script src="/js/jquery.1.5.js" type="text/javascript"></script>
    <script src="/js/jquery.js" type="text/javascript"></script>  
    <script src="/js/JQueryzTreev3.5/js/jquery.ztree.all-3.5.min.js" type="text/javascript"></script>
    <script src="/js/jquery.nhis.js" type="text/javascript"></script> 
    <script src="/js/jquery.rchis.js" type="text/javascript"></script>
    <script src="/js/jquery-ui-custom.min.js" type="text/javascript"></script>
    <script src="/js/css.js" type="text/javascript"></script> 
    <script src="/js/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="/js/Common.js" type="text/javascript"></script>
    <script src="/js/jquery.json.js" type="text/javascript"></script>  
    <script src="/js/Uppop/tipswindown.js" type="text/javascript"></script>
    <script type="text/javascript">
        var zTree;
        var treeNodes;
        //zTree基本设置
        var setting = {
            check: {
                enable: true,
                chkStyle: "checkbox",
                chkboxType: { "Y": "ps", "N": "ps" }
            },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "ID",
                    pIdKey: "PID",
                    rootPId: 0
                },
                key: {
                    name: "NAME"
                }
            },
            view: {
                dblClickExpand: true,
                showLine: true,
                selectedMulti: false
            }
        };
        var AppPath = '<%=AppPath %>';
        var handler = AppPath + '/do/Product/Stock_In.do';
        $(function () {
            // 确定按钮的单击事件
            $('#BtnSave').click(function () {
                var check_nodes = zTree.getCheckedNodes(true); // 获取选中的
                //alert(check_nodes.length);
                var check_three_nodes = new Array(); //第三级节点
                //                var check_two_nodes = new Array(); //第二级节点
                //                var check_one_nodes = new Array(); //第一级节点
                for (var i = 0; i < check_nodes.length; i++) {
                    if (check_nodes[i].level == 2) { //第三级节点
                        check_three_nodes.push(check_nodes[i].ID);
                    }
                    //                    else if(check_nodes[i]==1){   //第二级节点
                    //                        module_role_trees.push(check_nodes[i].ID);
                    //                    }else if (check_nodes[i] == 0) {   //第一级节点
                    //                        module_role_trees.push(check_nodes[i].ID);
                    //                    }
                }
                var check_three_nodes_id = '';
                for (var i = 0; i < check_three_nodes.length; i++) {
                    check_three_nodes_id += check_three_nodes[i] + ',';
                }
                check_three_nodes_id = check_three_nodes_id.substr(0, check_three_nodes_id.length - 1);
                parent.tipsWindown.close(); //关闭弹出层
                window.parent.popRetuInfo(check_three_nodes_id, '');

            });

            //取消按钮的事件
            $('#BtnCancel').click(function () {
                parent.tipsWindown.close();
                window.parent.popRetuInfo('', '');
            });
            // 生成树结构
            initTree();
        });
        //初始化分类树
        function initTree() {
            $.post(handler, { ActionName: 'GetProduct_SortTree' }, function (rslt) {
                if (!rslt.Success) {
                    alert(rslt.Message);
                    return;
                }
                treeNodes = rslt.Data; //把后台封装好的简单Json格式赋给treeNodes
                //alert(data.length);   
                $.fn.zTree.init($("#ztree_category"), setting, treeNodes);
                //zTree.expandNode(treeNodes[0], true, false); // 展开第一个
                //isTreeSucceed = true; // 表示加载成功
                zTree = $.fn.zTree.getZTreeObj("ztree_category");
            }, 'json');

        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input id="BtnSave" type="button"  class="btn77"  value="确定" />  
        <input id="BtnCancel" type="button"  class="btn77"   value="取消" /> 
    </div>
    <div id="div_tree" style=" display:block">
            <!--控件树对话框--> 
            <ul id="ztree_category" class="ztree">
            </ul> 
    </div>
    </form>
</body>
</html>
